//LuoFeng Nanami ver.
#include<bits/stdc++.h>
#define ll long long
#define rll register ll
#define F(i, a, b) for(rll i = a; i <= b; i++)
#define Fdn(i, a, b) for(rll i = a; i >= b; i--)
#define int ll
#define ld long double
#define pii pair<int, int>
#define fi first
#define se second

using namespace std;
const int inf = 0x3f3f3f3f3f3f3f3f, mod = 1e9 + 7, _mod = 998244353;
const int maxn = 1e5 + 7, maxm = 1e6 + 7;
const ld eps = 1e-7;

int _;
int n, m, L, V;
int d[maxn], v[maxn], a[maxn];
int p[maxn];
int rnk[maxm];
pii dat[maxn];

inline bool cmp(pii a, pii b) {
    if(a.fi == b.fi) return a.se < b.se;
    return a.fi < b.fi;
}

/*int Mx[maxn << 2], Mn[maxn << 2], LazyMx[maxn << 2], LazyMn[maxn << 2];
inline void PushDown(int p, int l, int r) {
    int mid = (l + r) >> 1;
    if(LazyMx[p] != -inf) {
        LazyMx[p << 1] = max(LazyMx[p << 1], LazyMx[p]);
        LazyMx[p << 1 | 1] = max(LazyMx[p << 1 | 1], LazyMx[p]);
        if(l == mid) Mx[p << 1] = max(Mx[p << 1], LazyMx[p]);
        if(mid + 1 == r) Mx[p << 1 | 1] = max(Mx[p << 1 | 1], LazyMx[p]);
        LazyMx[p] = -inf;
    }
    if(LazyMn[p] != inf) {
        LazyMn[p << 1] = min(LazyMn[p << 1], LazyMn[p]);
        LazyMn[p << 1 | 1] = min(LazyMn[p << 1 | 1], LazyMn[p]);
        if(l == mid) Mn[p << 1] = min(Mn[p << 1], LazyMn[p]);
        if(mid + 1 == r) Mn[p << 1 | 1] = min(Mn[p << 1 | 1], LazyMn[p]);
        LazyMn[p] = inf;
    }
}

inline void Modify(int p, int l, int r, int s, int t, int v) {
    if(s <= l && r <= t) return LazyMx[p] = max(LazyMx[p], v), LazyMn[p] = min(LazyMn[p], v), void();
    int mid = (l + r) >> 1;
    PushDown(p, l, r);
    if(s <= mid) Modify(p << 1, l, mid, s, t, v);
    if(mid < t) Modify(p << 1 | 1, mid + 1, r, s, t, v);
}

inline pii Query(int p, int l, int r, int k) {
    if(l == r) return make_pair(Mn[p], Mx[p]);
    int mid = (l + r) >> 1;
    if(k <= mid) return Query(p << 1, l, mid, k);
    else return Query(p << 1 | 1, mid + 1, r, k);
}

int Tree2[maxn << 2], Mx2[maxn << 2], MxPos2[maxn << 2];*/

int dfans;
bool vis[25];
vector<int> hav[25];
inline void dfs(int x, int t, int li) {
    if(x == m + 1) {
        bool fl = 1;
        F(i, 1, li) fl &= vis[i];
        if(fl) dfans = min(dfans, t);
        return ;
    }
    dfs(x + 1, t, li);
    vector<int> vec;
    for(int i : hav[x]) if(!vis[i]) vec.push_back(i), vis[i] = 1;
    dfs(x + 1, t + 1, li);
    for(int i : vec) vis[i] = 0;
}


signed main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);

    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    cin >> _;
    while(_--) {
        dfans = inf;
        memset(rnk, 0, sizeof rnk);
        int tot = 0, ans = 0;
        bool flA = 1, flB = 1;
        cin >> n >> m >> L >> V;
        F(i, 1, n) { cin >> d[i] >> v[i] >> a[i]; if(a[i] != 0) flA = 0; if(a[i] <= 0) flB = 0; }
        int lst = -1;
        F(i, 1, m) {
            cin >> p[i];
            F(j, lst + 1, p[i]) rnk[j] = i;
            lst = p[i];
        }
        F(j, lst + 1, L) rnk[j] = m + 1;
        F(i, 1, n) {
            if(a[i] == 0) {
                if(v[i] > V) {
                    if(rnk[d[i]] != m + 1) {
                        dat[++tot].fi = rnk[d[i]];
                        dat[tot].se = m;
                        //cout << i << " " << dat[tot].fi << " " << dat[tot].se << '\n';
                    }
                }
            }
            else if(a[i] > 0) {
                if(v[i] > V) {
                    if(rnk[d[i]] != m + 1) {
                        dat[++tot].fi = rnk[d[i]];
                        dat[tot].se = m;
                        //cout << i << " " << dat[tot].fi << " " << dat[tot].se << '\n';
                    }
                }
                else if(v[i] == V) {
                    if(rnk[d[i] + 1] != m + 1) {
                        dat[++tot].fi = rnk[d[i]];
                        dat[tot].se = m;
                        //cout << i << " " << dat[tot].fi << " " << dat[tot].se << '\n';
                    }
                }
                else {
                    ld fv = sqrt((ld)v[i] * (ld)v[i] + (ld)2 * (ld)a[i] * (ld)(L - d[i]));
                    if(fv > (ld)V) {
                        ld st = (ld)d[i] + (ld)(V * V - v[i] * v[i]) / (ld)(2 * a[i]);
                        if(st < (ld)d[i]) continue;
                        if(st < (ld)p[m]) {
                            //cout << st << '\n';
                            if((int)st == (int)ceil(st)) dat[++tot].fi = rnk[(int)ceil(st) + 1];
                            else dat[++tot].fi = rnk[(int)ceil(st)];
                            dat[tot].se = m;
                            //cout << i << " " << dat[tot].fi << " " << dat[tot].se << '\n';
                        }
                    }
                }
            }
            else {
                if(v[i] > V) {
                    int st = d[i] + ceil((ld)(V * V - v[i] * v[i]) / (ld)(2 * a[i]));
                    if(st > L) {
                        dat[++tot].fi = rnk[d[i]];
                        dat[tot].se = m;
                        //cout << i << " " << dat[tot].fi << " " << dat[tot].se << '\n';
                    }
                    else {
                        if(rnk[d[i]] != rnk[st]) {
                            dat[++tot].fi = rnk[d[i]];
                            dat[tot].se = rnk[st] - 1;
                            //cout << i << " " << dat[tot].fi << " " << dat[tot].se << '\n';
                        }
                    }
                }
            }
        }
        if(flA || flB) cout << tot << " " << (tot == 0 ? m : m - 1) << '\n';
        if(n <= 20) {
            sort(dat + 1, dat + 1 + tot, cmp);
            F(i, 1, m) hav[i].clear();
            F(i, 1, tot) {
                //cout << i << " " << dat[tot].fi << " " << dat[tot].se << '\n';
                F(j, dat[i].fi, dat[i].se) {
                    hav[j].push_back(i);
                }
            }
            /*F(i, 1, m) {
                cout << endl;
                for(int j : hav[i]) cout << j << " ";
                cout << endl << endl;
            }*/
            dfs(1, 0, tot);
            cout << tot << " " << (tot == 0 ? m : m - dfans) << '\n';
        }
    }

    return 0;
}